from selenium import webdriver
from time import sleep
from selenium.webdriver.common.by import By
from selenium.webdriver import ActionChains
from selenium.webdriver.support.select import Select
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.support import  expected_conditions
driver = webdriver.Chrome()
driver.get("http://localhost/ranzhi/www/crm/customer-browse.html")
driver.maximize_window()
WebDriverWait(driver,10).until(expected_conditions.presence_of_element_located((By.ID,"account")))
driver.find_element(By.ID,"account").send_keys("123456")
WebDriverWait(driver,10).until(expected_conditions.presence_of_element_located((By.NAME,"password")))
driver.find_element(By.NAME,"password").send_keys("123456")
WebDriverWait(driver,10).until(expected_conditions.presence_of_element_located((By.ID,"submit")))
driver.find_element(By.ID,"submit").click()
WebDriverWait(driver,10).until(expected_conditions.presence_of_element_located((By.XPATH,"/html/body/div[1]/div[1]/div/ul[1]/li[2]/button/img")))
driver.find_element(By.XPATH,"/html/body/div[1]/div[1]/div/ul[1]/li[2]/button/img").click()
WebDriverWait(driver,10).until(expected_conditions.frame_to_be_available_and_switch_to_it("iframe-1"))
WebDriverWait(driver,10).until(expected_conditions.presence_of_element_located((By.XPATH,"/html/body/div[2]/div[1]/a")))
driver.find_element(By.XPATH,"/html/body/div[2]/div[1]/a").click()
WebDriverWait(driver,10).until(expected_conditions.presence_of_element_located((By.ID,"name")))
driver.find_element(By.ID,"name").send_keys("售卖核武器")
WebDriverWait(driver,10).until(expected_conditions.presence_of_element_located((By.ID,"contact")))
driver.find_element(By.ID,"contact").send_keys("赵")
WebDriverWait(driver,10).until(expected_conditions.presence_of_element_located((By.ID,"phone")))
driver.find_element(By.ID,"phone").send_keys("1101201199")
WebDriverWait(driver,10).until(expected_conditions.presence_of_element_located((By.ID,"email")))
driver.find_element(By.ID,"email").send_keys("110122@qq.com")
WebDriverWait(driver,10).until(expected_conditions.presence_of_element_located((By.ID,"qq")))
driver.find_element(By.ID,"qq").send_keys("1192")
WebDriverWait(driver,10).until(expected_conditions.presence_of_element_located((By.ID,"depositor")))
driver.find_element(By.ID,"depositor").send_keys("1230")
WebDriverWait(driver,10).until(expected_conditions.presence_of_element_located((By.ID,"type")))
ele=driver.find_element(By.ID,"type")
sle_obj=Select(ele)
sle_obj.select_by_value("limited")
WebDriverWait(driver,10).until(expected_conditions.presence_of_element_located((By.ID,"size")))
ele=driver.find_element(By.ID,"size")
sle_obj=Select(ele)
sle_obj.select_by_value("1")
WebDriverWait(driver,10).until(expected_conditions.presence_of_element_located((By.ID,"status")))
ele=driver.find_element(By.ID,"status")
sle_obj=Select(ele)
sle_obj.select_by_value("signed")
WebDriverWait(driver,10).until(expected_conditions.presence_of_element_located((By.ID,"level")))
ele=driver.find_element(By.ID,"level")
sle_obj=Select(ele)
sle_obj.select_by_value("B")
WebDriverWait(driver,10).until(expected_conditions.presence_of_element_located((By.XPATH,'/html/body/div/div[1]/div[2]/form/table/tbody/tr[13]/td/div[1]/input')))
driver.find_element(By.XPATH,'/html/body/div/div[1]/div[2]/form/table/tbody/tr[13]/td/div[1]/input').send_keys("兰州")
WebDriverWait(driver,10).until(expected_conditions.presence_of_element_located((By.XPATH,'/html/body/div/div[1]/div[2]/form/table/tbody/tr[13]/td/div[3]/input')))
driver.find_element(By.XPATH,'/html/body/div/div[1]/div[2]/form/table/tbody/tr[13]/td/div[3]/input').send_keys("中国")
WebDriverWait(driver,10).until(expected_conditions.presence_of_element_located((By.ID,"intension")))
driver.find_element(By.ID,"intension").send_keys("全部购买")
WebDriverWait(driver,10).until(expected_conditions.presence_of_element_located((By.ID,"submit")))
driver.find_element(By.ID,"submit").click()
sleep(5)
WebDriverWait(driver,10).until(expected_conditions.presence_of_element_located((By.LINK_TEXT,"客户")))
driver.find_element(By.LINK_TEXT,"客户").click()
WebDriverWait(driver,10).until(expected_conditions.presence_of_element_located((By.LINK_TEXT,"更多")))
driver.find_element(By.LINK_TEXT,"更多").click()
WebDriverWait(driver,10).until(expected_conditions.presence_of_element_located((By.LINK_TEXT,"删除")))
driver.find_element(By.LINK_TEXT,"删除").click()
alert=driver.switch_to.alert
alert.accept()
driver.switch_to.default_content()
WebDriverWait(driver,10).until(expected_conditions.presence_of_element_located((By.XPATH,'/html/body/div[1]/div[1]/div/ul[1]/li[8]/button')))
driver.find_element(By.XPATH,'/html/body/div[1]/div[1]/div/ul[1]/li[8]/button').click()
WebDriverWait(driver,10).until(expected_conditions.frame_to_be_available_and_switch_to_it("iframe-superadmin"))
WebDriverWait(driver,10).until(expected_conditions.presence_of_element_located((By.XPATH,'/html/body/div[2]/div/div/div[1]/div/a/h3')))
driver.find_element(By.XPATH,'/html/body/div[2]/div/div/div[1]/div/a/h3').click()
WebDriverWait(driver,10).until(expected_conditions.presence_of_element_located((By.ID,"account")))
driver.find_element(By.ID,"account").send_keys("775852111")
WebDriverWait(driver,10).until(expected_conditions.presence_of_element_located((By.ID,"realname")))
driver.find_element(By.ID,"realname").send_keys("1111")
WebDriverWait(driver,10).until(expected_conditions.presence_of_element_located((By.ID,"genderm")))
driver.find_element(By.ID,"genderm").click()
ele=driver.find_element(By.ID,"role")
sle_obj=Select(ele)
sle_obj.select_by_value("support")
WebDriverWait(driver,10).until(expected_conditions.presence_of_element_located((By.ID,"password1")))
driver.find_element(By.ID,"password1").send_keys("123456")
WebDriverWait(driver,10).until(expected_conditions.presence_of_element_located((By.ID,"password2")))
driver.find_element(By.ID,"password2").send_keys("123456")
WebDriverWait(driver,10).until(expected_conditions.presence_of_element_located((By.ID,"email")))
driver.find_element(By.ID,"email").send_keys("12011011999@qq.com")
WebDriverWait(driver,10).until(expected_conditions.presence_of_element_located((By.ID,"submit")))
driver.find_element(By.ID,"submit").click()
driver.switch_to.default_content()
WebDriverWait(driver,10).until(expected_conditions.presence_of_element_located((By.XPATH,'/html/body/div[1]/div[1]/div/ul[1]/li[8]/button')))
driver.find_element(By.XPATH,'/html/body/div[1]/div[1]/div/ul[1]/li[8]/button').click()
WebDriverWait(driver,10).until(expected_conditions.frame_to_be_available_and_switch_to_it("iframe-superadmin"))
WebDriverWait(driver,10).until(expected_conditions.presence_of_element_located((By.LINK_TEXT,"组织")))
driver.find_element(By.LINK_TEXT,"组织").click()
WebDriverWait(driver,10).until(expected_conditions.presence_of_element_located((By.XPATH,'/html/body/div/div/div/div[2]/div/div/table/tbody/tr[2]/td[11]/a[3]')))
driver.find_element(By.XPATH,'/html/body/div/div/div/div[2]/div/div/table/tbody/tr[2]/td[11]/a[3]').click()
alert=driver.switch_to.alert
alert.accept()
WebDriverWait(driver,10).until(expected_conditions.presence_of_element_located((By.LINK_TEXT,"签退")))
driver.find_element(By.LINK_TEXT,"签退").click()
driver.quit()
